package com.spzx.channel.service.impl;

import com.spzx.channel.service.CategoryService;
import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.exception.ServiceException;
import com.spzx.product.api.CategoryFeignClient;
import com.spzx.product.api.domain.vo.CategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CategoryServiceImpl
 * @Author 波
 * @Date 2024/8/5 16:43
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryFeignClient categoryFeignClient;

    @Override
    public List<CategoryVo> tree() {
        R<List<CategoryVo>> result = categoryFeignClient.getCategoryTree(SecurityConstants.INNER);
        if(R.FAIL== result.getCode()){
            throw new ServiceException(result.getMsg());
        }
        return result.getData();
    }
}
